<?php
    class Module {
        //Alias sur table : m
        public $id_module;
        public $libelle;
        public $valide;

        //Constructeur complet
        public function __construct($id_module, $libelle, $valide) {
            $this->setId($id_module);
            $this->setLibelle($libelle);
            $this->setValide($valide);
        }

        //Crée un objet Module grâce à son ID
        //Paramètre : (int)id
        //Retourne (Module)
        public static function rechercheModule($id) {
            $sql =  'SELECT
                        m.id_module as mid_module, m.libelle as mlibelle, m.valide as mvalide
                    FROM module m
                    WHERE
                        m.id_module = '.intval($id);
            $ps = Db::Execute($sql, true);
            foreach($ps as $p) {
                return new Module($p['mid_module'], $p['mlibelle'], $p['mvalide']);
            }
            return null;
        }

        //GETTERS ET SETTERS
        public function getId() {return $this->id_module;}
        public function getLibelle() {return $this->libelle;}
        public function getValide() {return $this->valide;}

        public function setId($temp) {$this->id_module = intval($temp);}
        public function setLibelle($temp) {$this->libelle = $temp;}
        public function setValide($temp) {$this->valide = intval($temp);}
    }

?>